package com.ctshk.sapp.scenic.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.scenic.dto.ScenicResourceDTO;
import com.ctshk.rpc.scenic.dto.ScenicResourceDetailDTO;
import com.ctshk.rpc.scenic.req.*;
import com.ctshk.rpc.scenic.service.IScenicResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;


/**
 * <p>
 * 门票产品 前端控制器
 * </p>
 *
 * @author wangcy
 * @since 2021-02-02
 */
@RestController
@RequestMapping("/scenic-resource")
@Api(value = "资源中心景点门票", tags = "资源中心景点门票")
public class ScenicResourceController extends BaseController {

    @DubboReference
    private IScenicResourceService iScenicResourceService;

    @ApiOperation(value = "产品列表", notes = "产品列表")
    @PostMapping(value = "/query-list")
    public Result<PageResponse<ScenicResourceDTO>> queryList(@RequestBody ScenicResourceReq scenicResourceReq) {
        return Result.success(iScenicResourceService.queryList(scenicResourceReq,getCurrentUser(getRequest())));
    }

    @ApiOperation(value = "批量修改售卖状态", notes = "批量修改售卖状态")
    @PostMapping(value = "/update-sale-status")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态修改", operDesc = "门票售卖状态修改")
    public Result<Long> updateSaleStatus(@RequestBody ScenicResourceSaleReq scenicResourceReq) {

        return iScenicResourceService.updateSaleStatus(scenicResourceReq, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "新增-编辑提交审批", notes = "新增-编辑提交审批")
    @PostMapping(value = "/update-approval-status")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态修改", operDesc = "门票售卖状态修改")
    public Result<String> submit(@RequestBody ScenicProductSubmitReq scenicProductSubmitReq) {

        return iScenicResourceService.submit(scenicProductSubmitReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "新增-审批", notes = "新增-审批")
    @PostMapping(value = "/update-approval-check")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态修改", operDesc = "门票售卖状态修改")
    public Result<Long> check(@RequestBody ScenicProductCheckReq scenicProductCheckReq) {

        return iScenicResourceService.check(scenicProductCheckReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "api批量设置", notes = "api批量设置")
    @PostMapping(value = "/update-api")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "api批量设置", operDesc = "api批量设置")
    public Result<Long> updateApi(@RequestBody ScenicResourceApiReq resourceApiReq) {

        return iScenicResourceService.updateApi(resourceApiReq);
    }

    @ApiOperation(value = "新增门票信息-产品设置", notes = "新增门票信息-产品设置")
    @PostMapping(value = "/save")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "门票售卖状态新增", operDesc = "门票售卖状态新增")
    public Result<Long> save(@RequestBody ScenicResourceProductReq resourceProductReq) {

        return iScenicResourceService.save(resourceProductReq, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "新增/编辑门票信息-预订设置", notes = "新增/编辑门票信息-预订设置")
    @PostMapping(value = "/save-subscribe")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "门票售卖状态新增", operDesc = "门票售卖状态新增")
    public Result<Long> saveAgen(@RequestBody ScenicProductSaveReq scenicProductSaveReq) {

        return iScenicResourceService.saveAgen(scenicProductSaveReq);
    }

    @ApiOperation(value = "查询门票详情", notes = "查询门票详情")
    @PostMapping(value = "/detail")
    public Result<ScenicResourceDetailDTO> detail(@RequestBody ScenicResourceDetailReq req) {

        return iScenicResourceService.detail(req.getId(),getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "门票信息-产品设置编辑", notes = "门票信息-产品设置编辑")
    @PostMapping(value = "/modify")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "门票售卖状态编辑", operDesc = "门票售卖状态编辑")
    public Result<Long> modify(@RequestBody @Valid ScenicResourceProductReq resourceProductReq) {

        return iScenicResourceService.modify(resourceProductReq,getCurrentUser(getRequest()));
    }

}
